﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FasterWPF
{
    public static class ScrollViewerStyle
    {
        /// <summary>
        /// Apply Default Style to ScrollViewer
        /// </summary>
        /// <param name="txb"></param>
        /// <returns></returns>
        public static void ApplyScrollViewerStrategy(ScrollViewer source, string mouseOverColor, string pressedColor, string backgroundColor)
        {
            source.Apply(settings =>
            {
                settings

                    ////VERTICAL SCROLLBAR
                    .SetVerticalScrollBarColor(Brushes.WhiteSmoke)
                    .SetVerticalScrollUpButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 4 L 7 4 L 3.5 0 Z")
                    .SetVerticalPageUpButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") //, "2", "White", new Thickness(3, 3, 3, 3))
                    .SetVerticalPageDownButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //,"5", "Gray", new Thickness(3, 3, 3, 3))
                    .SetVerticalScrollDownButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 3.5 4 L 7 0 Z")
                    .SetVerticalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    //HORIZONTAL SCROLLBAR
                    .SetHorizontalScrollBarColor(Brushes.WhiteSmoke)
                    .SetHorizontalScrollRightButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 4 4 L 0 8 Z")
                    .SetHorizontalPageRightButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //, "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalPageLeftButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") // , "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalScrollLeftButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 4 0 L 4 8 L 0 4 Z")
                    .SetHorizontalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    .SetScrollViewerCornerRectangleColor(Brushes.White);

                   // .SetVerticalScrollDownStepDelayAndInterval(1, 30, 3)
                    //.SetVerticalPageDownStepDelayAndInterval(25, 30, 3)
                   // .SetHorizontalScrollRightStepDelayAndInterval(10, 30, 3)
                    //.SetHorizontalPageRightStepDelayAndInterval(25, 30, 3)
                   // .SetVerticalThumbStep(1)
                   // .SetHorizontalThumbStep(1)
                   // .SetVerticalPageUpStepDelayAndInterval(25, 30, 3)
                   // .SetVerticalScrollUpStepDelayAndInterval(1, 30, 3)
                   // .SetHorizontalPageLeftStepDelayAndInterval(25, 30, 3)
                   // .SetHorizontalScrollLeftStepDelayAndInterval(10, 30, 3);
            });
        }

        /// <summary>
        /// Apply Default Style to T that has a ScrollViewer
        /// </summary>
        /// <param name="txb"></param>
        /// <returns></returns>
        public static void ApplyToScrollViewer<T>(T sourceWithScrollViewer, string mouseOverColor, string pressedColor, string backgroundColor)
            where T : FrameworkElement
        {
            sourceWithScrollViewer.Apply(settings =>
            {
                settings

                    ////VERTICAL SCROLLBAR
                    .SetVerticalScrollBarColor(Brushes.WhiteSmoke)
                    .SetVerticalScrollUpButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 4 L 7 4 L 3.5 0 Z")
                    .SetVerticalPageUpButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") //, "2", "White", new Thickness(3, 3, 3, 3))
                    .SetVerticalPageDownButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //,"5", "Gray", new Thickness(3, 3, 3, 3))
                    .SetVerticalScrollDownButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 3.5 4 L 7 0 Z")
                    .SetVerticalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    //HORIZONTAL SCROLLBAR
                    .SetHorizontalScrollBarColor(Brushes.WhiteSmoke)
                    .SetHorizontalScrollRightButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 4 4 L 0 8 Z")
                    .SetHorizontalPageRightButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //, "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalPageLeftButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") // , "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalScrollLeftButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 4 0 L 4 8 L 0 4 Z")
                    .SetHorizontalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    .SetScrollViewerCornerRectangleColor(Brushes.White);

                    //these logical scroll settings are deprecated. I force physical scrolling going forward!
                    //.SetVerticalScrollDownStepDelayAndInterval(1, 30, 3)
                    //.SetVerticalPageDownStepDelayAndInterval(25, 30, 3)
                    //.SetHorizontalScrollRightStepDelayAndInterval(10, 30, 3)
                    //.SetHorizontalPageRightStepDelayAndInterval(25, 30, 3)
                    //.SetVerticalThumbStep(1)
                    //.SetHorizontalThumbStep(1)
                    //.SetVerticalPageUpStepDelayAndInterval(25, 30, 3)
                    //.SetVerticalScrollUpStepDelayAndInterval(1, 30, 3)
                    //.SetHorizontalPageLeftStepDelayAndInterval(25, 30, 3)
                    //.SetHorizontalScrollLeftStepDelayAndInterval(10, 30, 3);
            });
        }

        /// <summary>
        /// Apply Default Style to T that has a ScrollViewer
        /// </summary>
        /// <param name="txb"></param>
        /// <returns></returns>
        public static void ApplyScrollViewerStrategy<T>(this T sourceWithScrollViewer, string mouseOverColor, string pressedColor, string backgroundColor)
            where T : FrameworkElement
        {
            sourceWithScrollViewer.Apply(settings =>
            {
                settings

                    ////VERTICAL SCROLLBAR
                    .SetVerticalScrollBarColor(Brushes.WhiteSmoke)
                    .SetVerticalScrollUpButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 4 L 7 4 L 3.5 0 Z")
                    .SetVerticalPageUpButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") //, "2", "White", new Thickness(3, 3, 3, 3))
                    .SetVerticalPageDownButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //,"5", "Gray", new Thickness(3, 3, 3, 3))
                    .SetVerticalScrollDownButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "Gray", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 3.5 4 L 7 0 Z")
                    .SetVerticalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    //HORIZONTAL SCROLLBAR
                    .SetHorizontalScrollBarColor(Brushes.WhiteSmoke)
                    .SetHorizontalScrollRightButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 0 0 L 4 4 L 0 8 Z")
                    .SetHorizontalPageRightButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //, "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalPageLeftButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") // , "#FFEE", "0", new Thickness(0, 0, 0, 0))
                    .SetHorizontalScrollLeftButtonColors("WhiteSmoke", mouseOverColor, pressedColor, pressedColor, pressedColor, "0", "#FFEE", new Thickness(1), "Black", mouseOverColor, "M 4 0 L 4 8 L 0 4 Z")
                    .SetHorizontalScrollThumbColors(backgroundColor, mouseOverColor, mouseOverColor, "#DDDDDD", "1", "1")

                    .SetScrollViewerCornerRectangleColor(Brushes.White);

                    //these logical scroll settings are deprecated. I force physical scrolling going forward!
                    //.SetVerticalScrollDownStepDelayAndInterval(1, 30, 3)
                    //.SetVerticalPageDownStepDelayAndInterval(25, 30, 3)
                    //.SetHorizontalScrollRightStepDelayAndInterval(10, 30, 3)
                    //.SetHorizontalPageRightStepDelayAndInterval(25, 30, 3)
                    //.SetVerticalThumbStep(1)
                    //.SetHorizontalThumbStep(1)
                    //.SetVerticalPageUpStepDelayAndInterval(25, 30, 3)
                    //.SetVerticalScrollUpStepDelayAndInterval(1, 30, 3)
                    //.SetHorizontalPageLeftStepDelayAndInterval(25, 30, 3)
                    //.SetHorizontalScrollLeftStepDelayAndInterval(10, 30, 3);
            });
        }

    }//end of class
}//end of namespace
